added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / CSSendWM_COPYDATA / ReadMe.txt
blob68d96609f85b1638a1a849b868e835f58b08ec2d
1 =============================================================================
2          WINDOWS APPLICATION : CSSendWM_COPYDATA Project Overview
3 =============================================================================
5 /////////////////////////////////////////////////////////////////////////////
6 Summary:
8 Inter-process Communication (IPC) based on the Windows message WM_COPYDATA is 
9 a mechanism for exchanging data among Windows applications in the local 
10 machine. The receiving application must be a Windows application. The data 
11 being passed must not contain pointers or other references to objects not 
12 accessible to the application receiving the data. While WM_COPYDATA is being 
13 sent, the referenced data must not be changed by another thread of the 
14 sending process. The receiving application should consider the data read-only. 
15 If the receiving application must access the data after SendMessage returns, 
16 it needs to copy the data into a local buffer.
18 This code sample demonstrates sending a custom data structure (MyStruct) to 
19 the receiving Windows application (CSReceiveWM_COPYDATA) by using 
20 SendMessage(WM_COPYDATA). If the data structure fails to be passed, the 
21 application displays the error code for diagnostics. A typical error code is 
22 0x5 (Access is denied) caused by User Interface Privilege Isolation (UIPI). 
23 UIPI prevents processes from sending selected window messages and other USER 
24 APIs to processes running with higher integrity. When the receiving 
25 application (CSReceiveWM_COPYDATA) runs at an integrity level higher than 
26 this sending application, you will see the "SendMessage(WM_COPYDATA) failed 
27 w/err 0x00000005" error message.
30 /////////////////////////////////////////////////////////////////////////////
31 Demo:
33 The following steps walk through a demonstration of the WM_COPYDATA samples.
35 Step1. After you successfully build the CSSendWM_COPYDATA and 
36 CSReceiveWM_COPYDATA sample projects in Visual Studio 2008, you will get the 
37 applications: CSSendWM_COPYDATA.exe and CSReceiveWM_COPYDATA.exe. 
39 Step2. Run CSSendWM_COPYDATA.exe and CSReceiveWM_COPYDATA.exe. In 
40 CSSendWM_COPYDATA, input the Number and Message fields.
42   Number: 123456
43   Message: Hello World
45 Then click the SendMessage button. The number and the message will be sent 
46 to CSReceiveWM_COPYDATA through a WM_COPYDATA message. When 
47 CSReceiveWM_COPYDATA receives the message, the application extracts the 
48 number and the message, and display them in the window.
51 /////////////////////////////////////////////////////////////////////////////
52 Sample Relation:
53 (The relationship between the current sample and the rest samples in 
54 Microsoft All-In-One Code Framework http://1code.codeplex.com)
56 CSSendWM_COPYDATA -> CSReceiveWM_COPYDATA
57 CSSendWM_COPYDATA sends data to CSReceiveWM_COPYDATA through the WM_COPYDATA 
58 message.
61 /////////////////////////////////////////////////////////////////////////////
62 Code Logic:
64 1. Find the handle of the receiving window (FindWindow)
66 2. Prepare the COPYDATASTRUCT struct with the data to be sent. 
67 (COPYDATASTRUCT)
69 3. Send the COPYDATASTRUCT struct through the WM_COPYDATA message to the 
70 receiving window.
73 /////////////////////////////////////////////////////////////////////////////
74 References:
76 WM_COPYDATA Message
77 http://msdn.microsoft.com/en-us/library/ms649011(VS.85).aspx
80 /////////////////////////////////////////////////////////////////////////////